package com.pie4cloud.pie.job.executor.services.impl;

import com.pie4cloud.pie.common.core.util.RedisUtil;
import com.pie4cloud.pie.job.executor.dto.StatisticalRequest;
import com.pie4cloud.pie.job.executor.enums.StatisticalType;
import com.pie4cloud.pie.job.executor.services.StatisticalBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StatisticalBaseServiceImpl implements StatisticalBaseService {
	protected static String STATISTICAL_GATHER = "STATISTICAL:GATHER:";
	protected static String STATISTICAL_DECODE = "STATISTICAL:DECODE:";
	protected static String STATISTICAL_DISPENSE = "STATISTICAL:DISPENSE:";
	protected static String STATISTICAL_NUM = "STATISTICAL:NUM:";

	@Autowired
	protected RedisUtil redisUtil;

	public StatisticalType getStatisticalType() {
		return StatisticalType.BASE;
	}


	public void doOperation(StatisticalRequest statisticalRequest) {
	}

	@Override
	public boolean check(StatisticalRequest statisticalRequest) {
		return false;
	}
	public void doExecute(String statisticalKey,String statisticalNum,StatisticalRequest statisticalRequest){
		redisUtil.sSetAndTime(statisticalKey,30*24*60*60*1000,statisticalRequest.getFilePath());
		long num=redisUtil.sGetSetSize(statisticalKey);
		redisUtil.hset(statisticalNum,statisticalRequest.getStatisticalType().name(),num,30*24*60*60*1000);
	}
}
